﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Windows.Forms;

namespace WinForm {
    public partial class FormGroupDetail : Form {
        BLL.ContactGroup group = new BLL.ContactGroup();
        int id;
        public FormGroupDetail(int id) {
            this.id = id;
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e) {

        }

        private void FormGroupDetail_Load(object sender, EventArgs e) {
            Model.ContactGroup model = new Model.ContactGroup();
            model = group.GetModel(id);
            txtName.Text = model.GroupName;
            txtMemo.Text = model.Memo;
            txtId.Text = model.Id.ToString();
        }



        private void btnClose_Click(object sender, EventArgs e) {
            this.Close();
        }

        private void btnSave_Click(object sender, EventArgs e) {
            Model.ContactGroup model = new Model.ContactGroup();
            model.Id = Convert.ToInt32(txtId.Text);
            model.GroupName = txtName.Text.Trim();
            model.Memo = txtMemo.Text.Trim();
            string msg;
            if (group.Update(model, out msg)) {

                MessageBox.Show("修改成功。");
            }
            else {
                MessageBox.Show(msg);
            }
            this.Close();
        }
    }
}
